class Solution {
public:
    int bestTiming(vector<int>& prices) 
    {
        if(prices.size() == 0) return 0;
        int minval = 0x3f3f3f3f,ret = -0x3f3f3f3f;
        for(int i = 0;i < prices.size();i++)
        {
            minval=min(prices[i],minval);
            ret = max(ret,prices[i]-minval);
        }
        return ret;
    }
};
